import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEMSLogicLink } from './ipsdemslogic-link';
import { IPSDEMSLogicNode } from './ipsdemslogic-node';
import { IPSDEMainState } from '../mainstate/ipsdemain-state';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMSLogicNodeImpl extends PSModelObjectImpl implements IPSDEMSLogicNode {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get leftPos(): number {
    return this.M.leftPos != null ? this.M.leftPos : 0;
  }

  get logicNodeType():
    | 'BEGIN'
    | 'DEACTION'
    | 'PREPAREPARAM'
    | 'RESETPARAM'
    | 'COPYPARAM'
    | 'BINDPARAM'
    | 'APPENDPARAM'
    | 'SORTPARAM'
    | 'RENEWPARAM'
    | 'FILTERPARAM'
    | 'FILTERPARAM2'
    | 'MERGEPARAM'
    | 'AGGREGATEPARAM'
    | 'LOOPSUBCALL'
    | 'RAWSQLCALL'
    | 'RAWSQLANDLOOPCALL'
    | 'RAWWEBCALL'
    | 'STARTWF'
    | 'CANCELWF'
    | 'THROWEXCEPTION'
    | 'SFPLUGIN'
    | 'RAWSFCODE'
    | 'SYSLOGIC'
    | 'SYSUTIL'
    | 'PREPAREJSPARAM'
    | 'VIEWCTRLINVOKE'
    | 'RAWJSCODE'
    | 'MSGBOX'
    | 'PFPLUGIN'
    | 'DEUIACTION'
    | 'MAINSTATE'
    | 'DEDATASET'
    | 'DENOTIFY'
    | 'DELOGIC'
    | 'COMMIT'
    | 'ROLLBACK'
    | 'DEBUGPARAM'
    | 'DEDATAQUERY'
    | 'DEPRINT'
    | 'DEREPORT'
    | 'DEDTSQUEUE'
    | 'DEDATASYNC'
    | 'DEDATAIMP'
    | 'DEDATAEXP'
    | 'DEDATAAUDIT'
    | 'SUBSYSSAMETHOD'
    | 'SYSDATASYNCAGENTOUT'
    | 'SYSDBTABLEACTION'
    | 'SYSBDTABLEACTION'
    | 'SYSSEARCHDOCACTION'
    | 'SYSBIREPORT'
    | 'END' {
    return this.M.logicNodeType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdemslogiclinks: IPSDEMSLogicLink[] | null = null;

  getPSDEMSLogicLinks(): IPSDEMSLogicLink[] | null {
    if (this.psdemslogiclinks == null) {
      this.psdemslogiclinks = this.fillChildListModel(this.M.getPSDEMSLogicLinks, 'dataentity.logic.IPSDEMSLogicLink') as IPSDEMSLogicLink[];
    }
    return this.psdemslogiclinks;
  }

  get psDEMSLogicLinks(): IPSDEMSLogicLink[] | null {
    return this.getPSDEMSLogicLinks();
  }

  findPSDEMSLogicLink(objKey: any): IPSDEMSLogicLink | null {
    return this.getPSModel5('dataentity.logic.IPSDEMSLogicLink', this.getPSDEMSLogicLinks(), objKey) as IPSDEMSLogicLink;
  }

  protected psdemainstate: IPSDEMainState | null = null;

  getPSDEMainState(): IPSDEMainState | null {
    if (this.psdemainstate != null) return this.psdemainstate;
    const value = this.M.getPSDEMainState;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdemainstate = ipsdataentity.findPSDEMainState(value);
    }
    return this.psdemainstate;
  }

  get psDEMainState(): IPSDEMainState | null {
    return this.getPSDEMainState();
  }

  getPSDEMainStateMust(): IPSDEMainState {
    const value = this.getPSDEMainState();
    if (value == null) {
      throw new Error('未指定实体主状态');
    }
    return value;
  }

  get topPos(): number {
    return this.M.topPos != null ? this.M.topPos : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get parallelOutput(): boolean {
    return this.M.parallelOutput;
  }

  get cls(): string {
    return 'PSDEMSLogicNodeImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEMSLogicNode') return true;
    return super.instanceof(cls);
  }
}
